package com.desay.pangoo.itmt.repository.rag;

import com.desay.pangoo.itmt.entity.rag.ChatEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @author uids1175
 */
@Repository
public interface ChatEntityRepository extends JpaSpecificationExecutor<ChatEntity>, PagingAndSortingRepository<ChatEntity, Long> {

    /**
     * 根据用户ID 获取历史记录
     */
    List<ChatEntity> findAllByUserId(String userId);

    ChatEntity findByChatId(Long chatId);

    @Modifying
    @Query("UPDATE ChatEntity c SET c.deleted = 1 WHERE c.chatId = :chatId")
    void deleteByChatId(@Param("chatId") Long chatId);
}
